package com.zzf.mall.order.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

/**
 * @Author 赵振飞
 * @Date 2022/10/25
 * @Version 1.0
 */
@Configuration
public class MySessionConfig {

    /**
     * 自定义session
     * @return
     */
    @Bean
    public CookieSerializer cookieSerializer(){
        DefaultCookieSerializer cookieSerializer =new DefaultCookieSerializer();
        cookieSerializer.setDomainName("zzf.com"); //存储的一级域名
        cookieSerializer.setCookieName("zzfsession");
        return cookieSerializer;
    }

    /**
     * 对存储在redis数据指定序列化处理
     * @return
     */
    @Bean
    public RedisSerializer<Object> redisSerializer(){
        return new GenericJackson2JsonRedisSerializer();
    }
}
